#include "UnorderedSet.h"
#include "UnorderedMap.h"
#include <stdio.h>
using namespace wnf;
#define _CRT_SECURE_NO_WARNINGS


void test_map1()
{
	/*unordered_map<int, int> um;*/
	//um.insert({ 1,10 });
	//um.insert({ 2,20 });
	//um.insert({ 3,30 });
	//um.insert({ 4,40 });
	//cout << um.find(1) << endl;
	//cout << um.find(5) << endl;
	//um.erase(1);
	//cout << um.find(1);

	unordered_map<string, int> um;
	um.insert({ "apple",1 });
	um.insert({ "pear",2 });
	um.insert({ "orange",3 });
}

void test_map2()
{
	unordered_map<int, int> um;
	um.insert({ 1,10 });
	um.insert({ 2,20 });
	um.insert({ 3,30 });
	um.insert({ 4,40 });
	unordered_map<int, int>::iterator it = um.begin();
	while (it != um.end())
	{
		cout << it->first << ':' << it->second << endl;
		it++;
	}
}

void test_map3()
{
	string arr[] = { "apple","pear","orange" ,"strawberry"};
	unordered_map<string, int> um;
	um.insert({ "apple",1 });
	um.insert({ "pear", 2 });
	for (const auto& e : arr)
	{
		um[e]++;
	}
	for (const auto& e : um)
	{
		cout << e.first << ':' << e.second << endl;
	}
}

void test_set1()
{
	unordered_set<int> us;
	us.insert({ 1 });
	us.insert({ 2 });
	us.insert({ 3 });
	us.insert({ 4 });
	us.insert({ 5 });
	//cout << us.find(1) << endl;
	//cout << us.find(6) << endl;
	//us.erase(1);
	//cout << us.find(1) << endl;
}

void test_set2()
{
	unordered_set<int> us;
	us.insert(1);
	us.insert(2);
	us.insert(3);
	us.insert(4);
	us.insert(5);

	unordered_set<int>::iterator it = us.begin();
	while (it != us.end())
	{
		cout << *it << endl;
		++it;
	}
}
int main()
{
	//test_map1();
	//test_set1();
	//test_map2();
	//test_set2();
	test_map3();
	return 0;
}